#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：python_learning 
@File ：database.py
@IDE  ：PyCharm 
@Author ：李涵彬
@Date ：2025/2/14 上午9:30 
"""

import sqlite3


class DatabaseManager:
	def __init__(self, db_path):
		self.db_path = db_path

	def get_data(self):
		conn = sqlite3.connect(self.db_path)
		cursor = conn.cursor()
		cursor.execute("SELECT * FROM data")
		result = cursor.fetchall()
		conn.close()
		return result

	def update_data(self, key, value):
		conn = sqlite3.connect(self.db_path)
		cursor = conn.cursor()
		cursor.execute("UPDATE data SET value = ? WHERE id = ?", (value, key))
		conn.commit()
		conn.close()
